package org.jeecg.modules.wlhy.hypricehistory.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.modules.wlhy.hypricehistory.entity.HyPriceHistory;
import org.jeecg.modules.wlhy.hypricehistory.mapper.HyPriceHistoryMapper;
import org.jeecg.modules.wlhy.hypricehistory.service.IHyPriceHistoryService;
import org.jeecg.modules.wlhy.order.entity.HyOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Date;
import java.util.List;

/**
 * @Description: 调价历史表
 * @Author: jeecg-boot
 * @Date:   2021-08-23
 * @Version: V1.0
 */
@Service
public class HyPriceHistoryServiceImpl extends ServiceImpl<HyPriceHistoryMapper, HyPriceHistory> implements IHyPriceHistoryService {

    @Autowired
    IHyPriceHistoryService hyPriceHistoryService;


    @Override
    public List<HyPriceHistory> getByOrderNum(String orderNum) {

        LambdaQueryWrapper <HyPriceHistory> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(HyPriceHistory::getOrderNum,orderNum);
        List<HyPriceHistory> listHyPriceHistory = this.list(queryWrapper);
        return listHyPriceHistory;

    }

    @Override
    public void setPriceHistory(HyOrder hyOrder) {

        HyOrder order = hyOrder;

        HyPriceHistory hyPriceHistory = new HyPriceHistory();
        Date d= new Date();
        hyPriceHistory.setOrderId(order.getId());
        hyPriceHistory.setCreateTime(d);
        hyPriceHistory.setOrderNum(order.getOrderNum());
        hyPriceHistory.setShippingType(order.getShippingType());
        hyPriceHistory.setShippingUnitPrice(order.getShippingUnitPrice());
        hyPriceHistory.setLossGoodsUnitPrice(order.getLossGoodsUnitPrice());
        hyPriceHistory.setLossType(order.getLossType());
        hyPriceHistory.setLossProportion(order.getLossProportion());
        //设置亏损比例
        //hyPriceHistory.setLossProportion2();
        hyPriceHistory.setIzUsedGas(order.getIzUsedGas());
        hyPriceHistory.setGasRechargeAmount(order.getGasRechargeAmount());

        //加入调价历史记录
        hyPriceHistoryService.save(hyPriceHistory);

    }

    /*@Override
    public void setPriceHistory(HyOrder hyOrder, String orderNum) {
        HyOrder order = hyOrder;

        HyPriceHistory hyPriceHistory = new HyPriceHistory();
        Date d= new Date();
        hyPriceHistory.setCreateTime(d);
        hyPriceHistory.setOrderNum(orderNum);
        hyPriceHistory.setShippingType(order.getShippingType());
        hyPriceHistory.setShippingUnitPrice(order.getShippingUnitPrice());
        hyPriceHistory.setLossGoodsUnitPrice(order.getLossGoodsUnitPrice());
        hyPriceHistory.setLossType(order.getLossType());
        hyPriceHistory.setLossProportion(order.getLossProportion());
        //设置亏损比例
        //hyPriceHistory.setLossProportion2();
        hyPriceHistory.setIzUsedGas(order.getIzUsedGas());
        hyPriceHistory.setGasRechargeAmount(order.getGasRechargeAmount());

        //加入调价历史记录
        hyPriceHistoryService.save(hyPriceHistory);
    }*/
}
